package com.ymatou.iapi.livebuyer.testcase;

import java.util.List;
import java.util.Map;

import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.experimental.categories.Category;

import com.google.gson.JsonArray;
import com.google.gson.JsonElement;
import com.ymatou.iapi.livebuyer.parameter.QueryLiveCategoryBean;
import com.ymatou.iapi.livebuyer.service.QueryLiveCategoryCall;
import com.ymt.core.tool.Logger;
import com.ymt.utils.annotation.*;
import com.ymt.utils.tag.*;
import com.ymttest.database.sqlwapper.LiveRoomWapper;
/**
*直播分类
*FreeMaker Template自动生成代码
*/
@TestSuite
public class Ts_QueryLiveCategory{
	private static QueryLiveCategoryBean querylivecategoryBean;
	private static QueryLiveCategoryCall querylivecategoryCall;
	@BeforeClass
	public static void setUp() {
		Logger.createResultFile("直播分类");
	}

	@Before
	public void caseUp() {
		querylivecategoryBean=new QueryLiveCategoryBean();
		querylivecategoryCall=new QueryLiveCategoryCall();
	}

	@AfterClass
	public static void tearDown() {
		Logger.generateResult(querylivecategoryCall.getOpurl());
	}

	@After
	public void caseDown() {
		Logger.end();
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_QueryLiveCategory_001() {
		Logger.start(true,"查询直播分类成功");
		try {
			querylivecategoryBean.setAppId("autotest");
			querylivecategoryCall.setData(querylivecategoryBean);
			querylivecategoryCall.callService();		
			Logger.verifyEquals("200", querylivecategoryCall.getString("code"), "验证code");
			List<Map> lm = new LiveRoomWapper().selectLivecategory();
			JsonArray ja = querylivecategoryCall.getJsonObject().get("data").getAsJsonArray();
			int i=0;
			for (JsonElement jsonElement : ja) {
//				Logger.debug("js:"+jsonElement.toString());
//				Logger.debug("mp:"+lm.get(i).toString());
				Logger.verifyEquals(lm.get(i).get("LiveCategoryId").toString(), jsonElement.getAsJsonObject().get("liveCategoryId").getAsString(), "验证LiveCategoryId");
				Logger.verifyEquals(lm.get(i).get("liveCategoryName"), jsonElement.getAsJsonObject().get("LiveCategoryName"), "验证liveCategoryName");
				Logger.verifyEquals(lm.get(i).get("OrderNo").toString(), jsonElement.getAsJsonObject().get("orderNo").getAsString(), "验证orderNo");
				i++;
			}
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
}